Divided reading first to avoid overflows
Cleaned up code indenting and comments.