Cleaning up pylint and pep8 errors in mobile API.

@ormsbee @jzoldak 

Mysteriously, it seems to behave the same. Pylint complained about using `block` before it was defined. Somehow, `block` was being defined outside of the loop; I think it inadvertently worked.