Fixed minor errors. TODO: Fix program crash at line 378.