Added output code comments and BASIC exeption handling.