Refinements and bug fixes