Nasty bunch of changes required to get .jar working