Committing some improvements that were implemented in schreyer version
of code.