big cleanup on the code

removed and/or updated comments and some refactoring
minor change to heade