Refactor coreio, fix for linux, make it build