Updating/adding further code from Tim's/Elan's implementation