Cleaned up the code and fixed compile.