Added portable library, fixed build errors