Removed commented out code, fixed some formatting, added some missing comments and fixed a small compiler warning.