Fix some erros and cleanup