Refactor

Can you leave a comment on why all this Marshal hackery :)