various portability fixes and color bug fix