Fixed various compilation bugs