Fixed various bugs in args parsing

mostly arrayoutofbounds exceptions