Fixed various bugs etc.