fixing many little errors and some missing imports