Fixed all principal bugs