Code bug fixes