More work on moving things to api.js
Fix problem with moving labels to front