Added constants for field size.

Added exceptions.
Refactored some code.