WIP: initialize using SMBuffer class
syntax cleanups
fix segfault