Large function splitted, ability to change base added.