A few random bug fixes