Fix for modular dependecies.

Turns out, the original code can not be so easily split into modular
files. This is a minimalist hack - changing as little code as necessary
to get the desired functionality. I added TODOs to refactor this later
to be cleaner and more modular.