DRY-ed code, and added LGPL header
Created App class in main file