moved some common functions/behaviour into common functions and init scripts