Improved code readability and added extensive comments.

Still need to integrate with the kernel and add custom serial interface
functions.