General patches

Fixed a few small bugs