session REFACTOR name changes and minor enhancements
diff --git a/src/session.c b/src/session.c
index 5a4fa18..8dfa00b 100644
--- a/src/session.c
+++ b/src/session.c
@@ -62,43 +62,43 @@
 }
 
 API NC_STATUS
-nc_get_session_status(const struct nc_session *session)
+nc_session_get_status(const struct nc_session *session)
 {
     return session->status;
 }
 
 API uint32_t
-nc_get_session_id(const struct nc_session *session)
+nc_session_get_id(const struct nc_session *session)
 {
     return session->id;
 }
 
 API NC_TRANSPORT_IMPL
-nc_get_session_ti(const struct nc_session *session)
+nc_session_get_ti(const struct nc_session *session)
 {
     return session->ti_type;
 }
 
 API const char *
-nc_get_session_username(const struct nc_session *session)
+nc_session_get_username(const struct nc_session *session)
 {
     return session->username;
 }
 
 API const char *
-nc_get_session_host(const struct nc_session *session)
+nc_session_get_host(const struct nc_session *session)
 {
     return session->host;
 }
 
 API uint16_t
-nc_get_session_port(const struct nc_session *session)
+nc_session_get_port(const struct nc_session *session)
 {
     return session->port;
 }
 
 API const char **
-nc_get_session_cpblts(const struct nc_session *session)
+nc_session_get_cpblts(const struct nc_session *session)
 {
     return session->cpblts;
 }
@@ -109,7 +109,7 @@
  *        >0 - error
  */
 static int
-session_ti_lock(struct nc_session *session, int timeout)
+session_ti_lock(struct nc_session *session, int32_t timeout)
 {
     int r;
 
@@ -438,10 +438,9 @@
 }
 
 int
-nc_connect_getsocket(const char* host, unsigned short port)
+nc_connect_getsocket(const char* host, uint16_t port)
 {
-    int sock = -1;
-    int i;
+    int i, sock = -1;
     struct addrinfo hints, *res_list, *res;
     char port_s[6]; /* length of string representation of short int */
 
@@ -803,7 +802,7 @@
 }
 
 NC_MSG_TYPE
-nc_recv_rpc(struct nc_session *session, int timeout, struct nc_server_rpc **rpc)
+nc_recv_rpc(struct nc_session *session, int32_t timeout, struct nc_server_rpc **rpc)
 {
     int r;
     struct lyxml_elem *xml = NULL;
@@ -862,7 +861,7 @@
 }
 
 static NC_MSG_TYPE
-get_msg(struct nc_session *session, int timeout, uint64_t msgid, struct lyxml_elem **msg)
+get_msg(struct nc_session *session, int32_t timeout, uint64_t msgid, struct lyxml_elem **msg)
 {
     int r;
     char *ptr;
@@ -1254,7 +1253,7 @@
 }
 
 API NC_MSG_TYPE
-nc_recv_reply(struct nc_session *session, struct nc_rpc *rpc, uint64_t msgid, int timeout, struct nc_reply **reply)
+nc_recv_reply(struct nc_session *session, struct nc_rpc *rpc, uint64_t msgid, int32_t timeout, struct nc_reply **reply)
 {
     struct lyxml_elem *xml;
     NC_MSG_TYPE msgtype = 0; /* NC_MSG_ERROR */
@@ -1357,7 +1356,7 @@
 }
 
 API NC_MSG_TYPE
-nc_send_rpc(struct nc_session *session, struct nc_rpc *rpc, int timeout, uint64_t *msgid)
+nc_send_rpc(struct nc_session *session, struct nc_rpc *rpc, int32_t timeout, uint64_t *msgid)
 {
     NC_MSG_TYPE r;
     struct nc_rpc_generic *rpc_gen;
diff --git a/src/session.h b/src/session.h
index 858fd6a..c6f7f9b 100644
--- a/src/session.h
+++ b/src/session.h
@@ -100,7 +100,7 @@
  *
  * @return Session status.
  */
-NC_STATUS nc_get_session_status(const struct nc_session *session);
+NC_STATUS nc_session_get_status(const struct nc_session *session);
 
 /**
  * @brief Get session ID.
@@ -109,7 +109,7 @@
  *
  * @return Session ID.
  */
-uint32_t nc_get_session_id(const struct nc_session *session);
+uint32_t nc_session_get_id(const struct nc_session *session);
 
 /**
  * @brief Get session transport used.
@@ -118,7 +118,7 @@
  *
  * @return Session transport.
  */
-NC_TRANSPORT_IMPL nc_get_session_ti(const struct nc_session *session);
+NC_TRANSPORT_IMPL nc_session_get_ti(const struct nc_session *session);
 
 /**
  * @brief Get session username.
@@ -127,7 +127,7 @@
  *
  * @return Session username.
  */
-const char *nc_get_session_username(const struct nc_session *session);
+const char *nc_session_get_username(const struct nc_session *session);
 
 /**
  * @brief Get session host.
@@ -136,7 +136,7 @@
  *
  * @return Session host.
  */
-const char *nc_get_session_host(const struct nc_session *session);
+const char *nc_session_get_host(const struct nc_session *session);
 
 /**
  * @brief Get session port.
@@ -145,7 +145,7 @@
  *
  * @return Session port.
  */
-uint16_t nc_get_session_port(const struct nc_session *session);
+uint16_t nc_session_get_port(const struct nc_session *session);
 
 /**
  * @brief Get session capabilities.
@@ -154,7 +154,7 @@
  *
  * @return Session capabilities.
  */
-const char **nc_get_session_cpblts(const struct nc_session *session);
+const char **nc_session_get_cpblts(const struct nc_session *session);
 
 /**
  * @brief Connect to the NETCONF server via proviaded input/output file descriptors.
@@ -189,7 +189,7 @@
  *
  * Function is provided only via nc_client.h header file and only when libnetconf2 is compiled with libssh support.
  */
-void nc_client_init_ssh(void);
+void nc_ssh_client_init(void);
 
 /**
  * @brief Destroy any dynamically allocated SSH-specific context.
@@ -199,7 +199,7 @@
  *
  * Function is provided only via nc_client.h header file and only when libnetconf2 is compiled with libssh support.
  */
-void nc_client_destroy_ssh(void);
+void nc_ssh_client_destroy(void);
 
 /**
  * @brief Connect to the NETCONF server using SSH transport (via libssh).
@@ -213,7 +213,7 @@
  *                 'localhost' is used by default if NULL is specified.
  * @param[in] port Port number of the target server. Default value 830 is used if 0 is specified.
  * @param[in] username Name of the user to login to the server. The user running the application (detected from the
- *                 effective UID) is used if NULL is specified.
+ *                     effective UID) is used if NULL is specified.
  * @param[in] ctx Optional parameter. If set, provides strict YANG context for the session
  *                (ignoring what is actually supported by the server side). If not set,
  *                YANG context is created for the session using \<get-schema\> (if supported
@@ -221,9 +221,9 @@
  *                (see nc_schema_searchpath()). In every case except not providing context
  *                to connect to a server supporting \<get-schema\> it is possible that
  *                the session context will not include all the models supported by the server.
- * @return Created NETCONF session object or NULL in case of error.
+ * @return Created NETCONF session object or NULL on error.
  */
-struct nc_session *nc_connect_ssh(const char *host, unsigned short port, const char* username, struct ly_ctx *ctx);
+struct nc_session *nc_connect_ssh(const char *host, uint16_t port, const char* username, struct ly_ctx *ctx);
 
 /**
  * @brief Connect to the NETCONF server using the provided SSH (libssh) session.
@@ -244,7 +244,7 @@
  *                (see nc_schema_searchpath()). In every case except not providing context
  *                to connect to a server supporting \<get-schema\> it is possible that
  *                the session context will not include all the models supported by the server.
- * @return Created NETCONF session object or NULL in case of error.
+ * @return Created NETCONF session object or NULL on error.
  */
 struct nc_session *nc_connect_libssh(ssh_session ssh_session, struct ly_ctx *ctx);
 
@@ -278,7 +278,7 @@
  *
  * @return EXIT_SUCCESS on success, EXIT_FAILURE otherwise.
  */
-int nc_add_ssh_keypair(const char *pub_key, const char *priv_key);
+int nc_ssh_add_keypair(const char *pub_key, const char *priv_key);
 
 /**
  * @brief Remove an SSH public and private key pair that was used for client authentication.
@@ -289,14 +289,14 @@
  *
  * @return EXIT_SUCCESS on success, EXIT_FAILURE otherwise.
  */
-int nc_del_ssh_keypair(int idx);
+int nc_ssh_del_keypair(int idx);
 
 /**
  * @brief Get the number of public an private key pairs set to be used for client authentication.
  *
  * @return Set keypair count.
  */
-int nc_get_ssh_keypair_count(void);
+int nc_ssh_get_keypair_count(void);
 
 /**
  * @brief Get a specific keypair set to be used for client authentication.
@@ -307,7 +307,7 @@
  *
  * @return EXIT_SUCCESS on success, EXIT_FAILURE otherwise.
  */
-int nc_get_ssh_keypair(int idx, const char **pub_key, const char **priv_key);
+int nc_ssh_get_keypair(int idx, const char **pub_key, const char **priv_key);
 
 /**
  * @brief Set SSH authentication method preference.
@@ -317,7 +317,7 @@
  * @param[in] auth_type Authentication method to modify the prefrence of.
  * @param[in] pref Preference of \p auth_type. Negative values disable the method.
  */
-void nc_set_ssh_auth_pref(NC_SSH_AUTH_TYPE auth_type, short int pref);
+void nc_ssh_set_auth_pref(NC_SSH_AUTH_TYPE auth_type, short int pref);
 
 /**
  * @brief Get SSH authentication method preference.
@@ -328,7 +328,7 @@
  *
  * @return Preference of the \p auth_type.
  */
-short int nc_get_ssh_auth_pref(NC_SSH_AUTH_TYPE auth_type);
+short int nc_ssh_get_auth_pref(NC_SSH_AUTH_TYPE auth_type);
 
 #endif /* ENABLE_SSH */
 
@@ -354,7 +354,7 @@
  *
  * @return EXIT_SUCCESS on success, EXIT_FAILURE otherwise.
  */
-int nc_client_init_tls(const char *client_cert, const char *client_key, const char *ca_file, const char *ca_dir,
+int nc_tls_client_init(const char *client_cert, const char *client_key, const char *ca_file, const char *ca_dir,
                        const char *crl_file, const char *crl_dir);
 
 /**
@@ -364,7 +364,7 @@
  *
  * Function is provided only via nc_client.h header file and only when libnetconf2 is compiled with TLS support.
  */
-void nc_client_destroy_tls(void);
+void nc_tls_client_destroy(void);
 
 /**
  * @brief Connect to the NETCONF server using TLS transport (via libssl)
@@ -431,7 +431,7 @@
  * @return NC_MSG_REPLY for success, NC_MSG_WOULDBLOCK if timeout reached and NC_MSG_ERROR
  *         when reading has failed.
  */
-NC_MSG_TYPE nc_recv_reply(struct nc_session *session, struct nc_rpc *rpc, uint64_t msgid, int timeout,
+NC_MSG_TYPE nc_recv_reply(struct nc_session *session, struct nc_rpc *rpc, uint64_t msgid, int32_t timeout,
                           struct nc_reply **reply);
 
 /**
@@ -445,7 +445,7 @@
  * @return NC_MSG_NOTIF for success, NC_MSG_WOULDBLOCK if timeout reached and NC_MSG_ERROR
  *         when reading has failed.
  */
-NC_MSG_TYPE nc_recv_notif(struct nc_session* session, int timeout, struct nc_notif **notif);
+NC_MSG_TYPE nc_recv_notif(struct nc_session* session, int32_t timeout, struct nc_notif **notif);
 
 /**
  * @brief Send NETCONF RPC message via the session.
@@ -456,6 +456,6 @@
  * @return #NC_MSG_RPC on success, #NC_MSG_WOULDBLOCK in case of busy session
  * (try to repeat the function call) and #NC_MSG_ERROR in case of error.
  */
-NC_MSG_TYPE nc_send_rpc(struct nc_session *session, struct nc_rpc *rpc, int timeout, uint64_t *msgid);
+NC_MSG_TYPE nc_send_rpc(struct nc_session *session, struct nc_rpc *rpc, int32_t timeout, uint64_t *msgid);
 
 #endif /* NC_SESSION_H_ */
diff --git a/src/session_p.h b/src/session_p.h
index 8eccd1a..4b11012 100644
--- a/src/session_p.h
+++ b/src/session_p.h
@@ -36,15 +36,15 @@
 #   include <libssh/callbacks.h>
 
 /* seconds */
-#   define SSH_TIMEOUT 10
-#   define SSH_AUTH_COUNT 3
+#   define NC_SSH_TIMEOUT 10
+#   define NC_SSH_AUTH_COUNT 3
 
 struct nc_ssh_auth_opts {
     /* SSH authentication method preferences */
     struct {
         NC_SSH_AUTH_TYPE type;
         short int value;
-    } auth_pref[SSH_AUTH_COUNT];
+    } auth_pref[NC_SSH_AUTH_COUNT];
 
     /* SSH key pairs */
     struct {
@@ -59,8 +59,8 @@
 
 #ifdef ENABLE_TLS
 
-#include <openssl/bio.h>
-#include <openssl/ssl.h>
+#   include <openssl/bio.h>
+#   include <openssl/ssl.h>
 
 struct nc_tls_auth_opts {
     SSL_CTX *tls_ctx;
@@ -70,7 +70,7 @@
 #endif /* ENABLE_TLS */
 
 /**
- * Sleep time in microseconds to wait between unsuccessful reading due to EAGAIN or EWOULDBLOCK
+ * Sleep time in microseconds to wait between unsuccessful reading due to EAGAIN or EWOULDBLOCK.
  */
 #define NC_READ_SLEEP 100
 
diff --git a/src/session_ssh.c b/src/session_ssh.c
index 81a717b..cb8901d 100644
--- a/src/session_ssh.c
+++ b/src/session_ssh.c
@@ -53,14 +53,14 @@
 };
 
 API void
-nc_client_init_ssh(void)
+nc_ssh_client_init(void)
 {
     ssh_threads_set_callbacks(ssh_threads_get_pthread());
     ssh_init();
 }
 
 API void
-nc_client_destroy_ssh(void)
+nc_ssh_client_destroy(void)
 {
     int i;
 
@@ -510,7 +510,7 @@
                 /* store the key into the host file */
                 ret = ssh_write_knownhost(session);
                 if (ret < 0) {
-                    WRN("Adding the known host %s failed (%s).", hostname, strerror(errno));
+                    WRN("Adding the known host %s failed (%s).", hostname, ssh_get_error(session));
                 }
             } else if (!strcmp("no", answer)) {
                 goto fail;
@@ -538,7 +538,7 @@
 }
 
 API int
-nc_add_ssh_keypair(const char *pub_key, const char *priv_key)
+nc_ssh_add_keypair(const char *pub_key, const char *priv_key)
 {
     int i;
     FILE *key;
@@ -596,7 +596,7 @@
 }
 
 API int
-nc_del_ssh_keypair(int idx)
+nc_ssh_del_keypair(int idx)
 {
     if (idx >= ssh_opts.key_count) {
         return EXIT_FAILURE;
@@ -614,13 +614,13 @@
 }
 
 API int
-nc_get_ssh_keypair_count(void)
+nc_ssh_get_keypair_count(void)
 {
     return ssh_opts.key_count;
 }
 
 API int
-nc_get_ssh_keypair(int idx, const char **pub_key, const char **priv_key)
+nc_ssh_get_keypair(int idx, const char **pub_key, const char **priv_key)
 {
     if (idx >= ssh_opts.key_count) {
         return EXIT_FAILURE;
@@ -637,7 +637,7 @@
 }
 
 API void
-nc_set_ssh_auth_pref(NC_SSH_AUTH_TYPE auth_type, short int pref)
+nc_ssh_set_auth_pref(NC_SSH_AUTH_TYPE auth_type, short int pref)
 {
     if (pref < 0) {
         pref = -1;
@@ -653,7 +653,7 @@
 }
 
 API short int
-nc_get_ssh_auth_pref(NC_SSH_AUTH_TYPE auth_type)
+nc_ssh_get_auth_pref(NC_SSH_AUTH_TYPE auth_type)
 {
     short int pref = 0;
 
@@ -716,7 +716,7 @@
     }
 
     /* select authentication according to preferences */
-    for (i = 0; i < SSH_AUTH_COUNT; i++) {
+    for (i = 0; i < NC_SSH_AUTH_COUNT; i++) {
         if (!(ssh_opts.auth_pref[i].type & auth)) {
             /* method not supported by server, skip */
             continue;
@@ -859,9 +859,9 @@
 }
 
 API struct nc_session *
-nc_connect_ssh(const char *host, unsigned short port, const char *username, struct ly_ctx *ctx)
+nc_connect_ssh(const char *host, uint16_t port, const char *username, struct ly_ctx *ctx)
 {
-    const int timeout = SSH_TIMEOUT;
+    const int timeout = NC_SSH_TIMEOUT;
     int sock;
     struct passwd *pw;
     struct nc_session *session = NULL;
diff --git a/src/session_tls.c b/src/session_tls.c
index b2c8534..e52f31f 100644
--- a/src/session_tls.c
+++ b/src/session_tls.c
@@ -160,7 +160,7 @@
 }
 
 API int
-nc_client_init_tls(const char *client_cert, const char *client_key, const char *ca_file, const char *ca_dir,
+nc_tls_client_init(const char *client_cert, const char *client_key, const char *ca_file, const char *ca_dir,
                    const char *crl_file, const char *crl_dir)
 {
     const char *key_ = client_key;
@@ -246,7 +246,7 @@
 }
 
 API void
-nc_client_destroy_tls()
+nc_tls_client_destroy()
 {
     CRYPTO_THREADID crypto_tid;