Started major overhaul of core functionality

Major changes revolve around conversion from string replacement to
element detection.