Fixed a few minors bugs