Code cleanup and naming fixes