Integrated Siva's methods to main loop. First version that compiles.