Test and bug fixes