Initial check in of code stolen from Riff-Raff