Big bug fixes