Moved parsing of attributes into its own method and fixed couple of bugs in the parsing logic.