Reduced redundant page requests. Restructured flow slightly.
Fixed errors in code.