Bug fixes, dynamic size calculation