Changed external functions and added docs