More functions and improvements