Fixed bug in variable write where wrong type was set (always=0)