Removed unused code and added minor fixes.