Added new constructor and cleaned up code