Renamed some methods.
Reordered functions.
Removed magic numbers.
Removed duplicate source code.