Moving init code into api