made a lot of fixes to pylon code and optimized it