Added comments and removed unused functions and fields