Reorganized code into objects