Fixed a bug. Cleaned un-used code.