fixed bugs due to latest changes (cleaning up)