Emi - bug fixes and add library