Fixes Issue186

[WIP] - I've got something working, but it needs fixes and cleanup.  This should help with the port to node.js for filer, though.