Refactor mobile javascript to get rid of console errors.

Fixes also mobile bookmarklet services.