Moved module related functions and things to separate file.