Add pragma marks and fix issues