Added request stack to main.
Split main() in multiple functions.
Fixed uninitialised var.
Code documentation.
Added datalen to store total data length in a data segment stack.