better detect debug mode, use api1 by default, more buffer fixes