use ? instead of if/else

unify argument names
unify variable names
replace if/else by ? operator
consolidate return types of Peek operations
formatting