Latest version of Nikhil's modifications