Update Common.py

Close connection when an error occured
Imports are in fucntions where they're used