Minor bugfixes and ansi c stuff