diff --git a/libmobile.c b/libmobile.c
index c6af4b000b884abba3f0e269c15a27bf717c4c52..67ad8e21d78933379f6ec7b01bb5c67af61240e3 100644
--- a/libmobile.c
+++ b/libmobile.c
@@ -56,7 +56,7 @@ static void curl_cleaner(CURLcode *curl)
 static size_t write_func(void *buffer, size_t size, size_t nmemb, void *data)
 {
 	struct string *str = (struct string *)data;
-	size_t len = size *nmemb;
+	size_t len = size * nmemb;
 	size_t new_len = str->len + (len);
 	char *tmp_ptr = str->ptr;
 
@@ -103,6 +103,7 @@ static int apn_profile_idx(struct json_object *apn_profiles, char *name)
 			return idx;
 		idx++;
 	}
+
 fail:
 	return -1;
 }
@@ -133,7 +134,6 @@ static int get_apn_profiles_len(void)
 			len++;
 		else
 			goto success;
-
 	}
 
 success:
@@ -161,7 +161,8 @@ fail:
  *		Will alter the input string and allocate memory for the return value!
  * 		The caller is responsible for freeing the return value.
  */
-static char *lexer(char **input, char *delimiter) {
+static char *lexer(char **input, char *delimiter)
+{
 	if (strlen(*input) == 0) {
 		printf("empty input!\n");
 		return NULL;
@@ -204,9 +205,7 @@ static char *get_query_wrapper(char *vars)
 
 	char query[1024] = {0};
 
-	strncpy(query, "http://192.168.0.1/goform/goform_get_cmd_process?isTest=false&cmd=", 1023);
-	strncat(query + strlen(query), vars, 1023);
-	strncat(query + strlen(query), "&multi_data=1", 1023);
+	snprintf(query, 1023, "http://192.168.0.1/goform/goform_get_cmd_process?isTest=false&cmd=%s&multi_data=1", vars);
 
 	return strdup(query);
 }
@@ -355,8 +354,8 @@ static struct json_object *parse_apn_profiles(struct json_object *apn_profiles)
 		}
 		char name[1024] = {0};
 
-		strncpy(name, "apn_config_", 1023);
-		sprintf(name + strlen(name), "%d", apn_counter);
+		snprintf(name, 1023, "apn_config_%d", apn_counter);
+
 		json_object_object_add(parsed_profiles, name, json_object_get(apn_profile));
 		json_object_put(apn_profile);
 		apn_counter++;
@@ -393,10 +392,8 @@ struct json_object *mobile_delete_apn(char *name)
 		printf("APN not found in list!\n");
 		goto fail_idx;
 	}
-	strncpy(query, "isTest=false&apn_action=delete&apn_mode=manual&index=", 1023);
-	sprintf(query + strlen(query), "%d", idx);
-	strncat(query + strlen(query), "&goformId=APN_PROC_EX", 1023);
 
+	snprintf(query, 1023, "isTest=false&apn_action=delete&apn_mode=manual&index=%d&goformId=APN_PROC_EX", idx);
 	json_object_put(apn_profiles);
 	return prepare_request(query, POST);
 
@@ -426,7 +423,7 @@ struct json_object *mobile_get_wan_apn(void)
 	return prepare_request("wan_apn", GET);
 }
 
-struct json_object *mobile_get_pinnumber(void)
+struct json_object *mobile_get_remaining_tries(void)
 {
 	return prepare_request("pinnumber", GET);
 }
@@ -463,20 +460,10 @@ struct json_object *mobile_create_apn_profile(char *profile_name, char *wan_apn,
 {
 	char query[1024] = {0};
 
-	//snprintf(query, 1023, "isTest=false&goformId=APN_PROC_EX&apn_action=save&apn_mode=manual&profile_name=%s&wan_dial=*99%23&apn_select=manual&pdp_type=\
+	snprintf(query, 1023, "isTest=false&goformId=APN_PROC_EX&apn_action=save&apn_mode=manual&profile_name=%s&wan_dial=*99%23&apn_select=manual&pdp_type=\
 	%s&pdp_select=auto&pdp_addr=&index=%d&wan_apn=%s&ppp_auth_mode=none&ppp_username=&ppp_passwd=&dns_mode=auto&prefer_dns_manual=&standby_dns_manual=",\
 	profile_name, pdp_type, get_apn_profiles_len(), wan_apn);
 
-	strncpy(query, "isTest=false&goformId=APN_PROC_EX&apn_action=save&apn_mode=manual&profile_name=", 1023);
-	strncat(query + strlen(query), profile_name, 1023);
-	strncat(query + strlen(query), "&wan_dial=*99%23&apn_select=manual&pdp_type=", 1023);
-	strncat(query + strlen(query), pdp_type, 1023);
-	strncat(query + strlen(query), "&pdp_select=auto&pdp_addr=&index=", 1023);
-	snprintf(query + strlen(query), 255, "%d", get_apn_profiles_len());
-	strncat(query + strlen(query), "&wan_apn=", 1023);
-	strncat(query + strlen(query), wan_apn, 1023);
-	strncat(query + strlen(query), "&ppp_auth_mode=none&ppp_username=&ppp_passwd=&dns_mode=auto&prefer_dns_manual=&standby_dns_manual=", 1023);
-
 	return prepare_request(query, POST);
 }
 
@@ -496,9 +483,8 @@ struct json_object *mobile_set_apn_profile(char *name)
 	}
 	char query[1024] = {0};
 
-	strncpy(query, "isTest=false&goformId=APN_PROC_EX&apn_mode=manual&apn_action=set_default&set_default_flag=1&pdp_type=IP&index=", 1023);
-	sprintf(query + strlen(query), "%d", idx);
-	printf("query %s\n", query);
+	snprintf(query, 1023, "isTest=false&goformId=APN_PROC_EX&apn_mode=manual&apn_action=set_default&set_default_flag=1&pdp_type=IP&index=%d", idx);
+
 	json_object_put(apn_profiles);
 	return prepare_request(query, POST);
 free_idx:
@@ -511,9 +497,7 @@ struct json_object *mobile_enable_pin(char *pin)
 {
 	char query[1024] = {0};
 
-	strncpy(query, "isTest=false&goformId=ENABLE_PIN&OldPinNumber=", 1023);
-	strncat(query + strlen(query), pin, 1023);
-	strncat(query + strlen(query), "&pin_save_flag=0&isTest=false", 1023);
+	snprintf(query, 1023, "isTest=false&goformId=ENABLE_PIN&OldPinNumber=%s&pin_save_flag=0&isTest=false", pin);
 
 	return prepare_request(query, POST);
 }
@@ -522,11 +506,7 @@ struct json_object *mobile_set_pin(char *current_pin, char *new_pin)
 {
 	char query[1024] = {0};
 
-	strncpy(query, "isTest=false&goformId=ENABLE_PIN&OldPinNumber=", 1023);
-	strncat(query + strlen(query), current_pin, 1023);
-	strncat(query + strlen(query), "&NewPinNumber=", 1023);
-	strncat(query + strlen(query), new_pin, 1023);
-	strncat(query + strlen(query), "&pin_save_flag=0&isTest=false", 1023);
+	snprintf(query, 1023, "isTest=false&goformId=ENABLE_PIN&OldPinNumber=%s&NewPinNumber=%s&pin_save_flag=0&isTest=false", current_pin, new_pin);
 
 	return prepare_request(query, POST);
 }
@@ -535,9 +515,7 @@ struct json_object *mobile_disable_pin(char *pin)
 {
 	char query[1024] = {0};
 
-	strncpy(query, "isTest=false&goformId=DISABLE_PIN&OldPinNumber=", 1023);
-	strncat(query + strlen(query), pin, 1023);
-	strncat(query + strlen(query), "&pin_save_flag=0&isTest=false", 1023);
+	snprintf(query, 1023, "isTest=false&goformId=DISABLE_PIN&OldPinNumber=%s&pin_save_flag=0&isTest=false", pin);
 
 	return prepare_request(query, POST);
-}
\ No newline at end of file
+}
diff --git a/libmobile.h b/libmobile.h
index 092b362afe03e20f9af881970725f5f92e9419dd..71586a4c741002a0b4edff9996bf0519c21422fa 100644
--- a/libmobile.h
+++ b/libmobile.h
@@ -122,15 +122,15 @@ struct json_object *mobile_get_roam_status(void);
 struct json_object *mobile_get_wan_apn(void);
 
 /**
- * Function: mobile_get_pinnumber
+ * Function: mobile_get_remaining_tries
  *
- * Gets the pinnumber, indicating how many tries are remaining before the SIM card is locked.
+ * Gets the pinnumber variable, indicating how many tries are remaining before the SIM card is locked.
  *
  * Returns:
  *		A pointer to a json_object containing the JSON response from the server. {"pinnumber": {1..3} } on success.
  *		NULL on failure.
  */
-struct json_object *mobile_get_pinnumber(void);
+struct json_object *mobile_get_remaining_tries(void);
 
 /**
  * Function: mobile_get_pin_status