Messages API and minor fixes