All the code - ready for submission (hopefully)