fixing class constructor bugs