Initial commit, mostly just extracted code from Paperclip