various fix and improvements