Api requests now handled by separate API module.
Login now uses newly added API module.

Note:
API module cannot handle error codes. Server-side error handling too
inconsistent.