Fixed errors while running as a module