Removed some duplicate code, shortened some things.