Sync from Facebook code base. Closes #19