Refactored to separate files. Added checker.