Some random bug fixes