Refactored code

Added a constants class, and some cleanup
Many changes may be shown due to usage of AnyEdit tools