Remove duplicate code

+ some other minor issues

Signed-off-by: Nico Rutishauser <nr@hotmail.ch>