Many minor fixes to make the module run properly