Fixed timer bug, added window api, other fixes