Added assertions

Added assertions regarding memory allocation
Fixed a multiplication bug