Cleaned up parser implementation and added documentation