Steal some core from dwt

https://github.com/aperezdc/dwt