Fix build errors

I've fixed a number of errors from building with the latest rust nightly, including the change of fail! to panic!