Minor fixes and changes to simplate.js, comments added.