WIP

There are probably plenty of things wrong with this. Read this code at your own peril.