Replaced magic numbers by enum.
Cleaned up several comments. Removed two unused variables.