Added extra functions and some fixes