Fixed various errors in merged branch