Fixes for all kinds of issues

Thanks to @jbtule, I grabbed all of this off his (google code)[https://code.google.com/r/jtuley-keyczar-dev/] fork.