moved some functions
internal cleanup