Ugh, manual open and close connections

This should be refactored later to use connection pooling.