moved several functions into standard library

Signed-off-by: Alexander Skjolden <alex@plastboks.net>