Add api constants and tidy