a few minor improvements and now it actually runs