As far as mappings, I wrote this awhile ago: https://github.com/tjwebb/casey.js/blob/master/casey.js