Various fix and improvements