Added error checks for initialization functions