further fixes and cleanup