Fixed various bugs
Various bug fixes (continued)