Fixed code so it compiles on the macs.

May have broken it for Sam.

Also simplified some things