Fixed import error and other bug fixes
More fixes and tweaks