Major changes, added comments