Lots o' bug fixes