Implemented logic operations and improved lots of other stuff.