clean code from legacy python implementation and segregated tornado app init