Improved logging, minor changes to code such as comments as well
more comments, added S_ERROR type but have not implemented it
small random changes