Updated a few bugs in code
Fixed some bugs with element retrieval.