Put some if-else-if's in switch statements

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
main: use a try-with-resources

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>