Major refactor of getattr()