Ini improvements

Fixes everything from #58 except the failing testcases. See #58 for more details about the testcases.