Added better bounds on possible rank, with ugly copy/pasted code because I'm lazy