Fixed compile problems, tested with examples/example1