implemented async map building and cleaned up