updated comments and cleand up all code