Refactored routes, added /api/{login,logout,register} support.