Promise

Added Promise support and some bug fixes