Added logging and moved everything inside of a common module