Polish and fix bugs