Moved static values into constants, and added more helpful error messages.