Fleshing out and cleaning up submit code