Rename functions added. Some minor bugs fixed