Improved reflection and made the code less redundant.