Improved Program Design

Separated functions into separate classes. Added ability to tweak
threshold values.