Formatted the code and added assertions for some constants to make it
more safe to change them.