Moved shared code into own module