Porting some commits from OpenJK. Cleaning up