Progress towards a nice solution; most of the code will have to be migrated to the main project