Multiple changes

Don't know if you are still active on this, but I've a few changes to add new features and correct a few bugs (from the original).