Debug option and fixes