Switch to use promises where possible