feature #1820: Fix EC2 server. Moved application logic to a separate class