Fixed the two most serious bugs