Implemented all the changes you suggested in a9a8f76