Functions added

Courtesy of Robert Lyxell