Fixed all the nasty compile errors