Updated with additional functions and did some cleanup