Fixed some BUGs and added $sync for promises