Code cleanup, added more callbacks