Added comments and removed some warnings