Removed unused functions and some minor changes