Updated with chmac's changes