Correct tabbing
Code cleanup

Improved error handling for creating connections and empty strings

Moved code in dedicated init and free methods.