Removed unuseful code. Fixed a pair of bugs.