Move modules out to a separate file and allow reloading (+ minor fixes)