removed redundant pieces of code
small fixes and comments