some fixes and cleanup