general bugfixes

null terminated magic string, improved frequency calculation, other
minor tweaks