Re-implemented EVERYTHING due to lack of structure in the old version.