bugfix: handling possible nullptr access.
update: replace clear be resize( 0 ) at some places to avoid double allocations ( only a micro optimization ).

Signed-off-by: Kim Kulling <kim.kulling@googlemail.com>