Corrected bug in size calculation and added prototypes