changed refrenece from .at to using constant access [] for speed, and improved constructors