Initial modifications of Nikhar's code.