fix compilation issues and cleanup