Cleaned up unused variables, fixed strange names, cosmetic changes etc.