Code cleanup and instancetype instead of id