Separate connection object and some refactoring
Set up for travis