Removed old code and global variables not used