Cleaned code. Added comments.