Added isset checks and ability to specify api (for internal debug use)