Fixed a little set of bugs noticed for a simple demo