Fixes to initial implementation - should be mostly working now