Cleaned up code. Made minor modifications.